Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always show cursor after control+c #2635

Merged
merged 15 commits into from
Jan 23, 2025

Conversation

ruben-arts
Copy link
Contributor

fixes #1548 #2625

The issue is related to and fixed with help of console-rs/dialoguer#77

@baszalmstra
Copy link
Contributor

I remember we explicitly removed ctrl+c handler at some point. @tdejager do you remember why?

@wolfv
Copy link
Member

wolfv commented Dec 3, 2024

We explicitly removed the CTRL+C handler in the pixi shell and the trampoline binaries because we want the underlying processes to handle CTRL+C. I am assuming that still works?

@wolfv
Copy link
Member

wolfv commented Dec 3, 2024

Also you can use ctrl_c from tokio so we don't need additional deps, check exec.rs.

src/cli/run.rs Outdated
@@ -326,6 +326,14 @@ fn disambiguate_task_interactive<'p>(
..ColorfulTheme::default()
};

// Ignore CTRL+C in the dialoguer prompt so that it shows the cursor again.
ctrlc::set_handler(move || {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still in favor of using tokio if we can make it work :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it back

@ruben-arts
Copy link
Contributor Author

I notice one weird thing with this change. It seems to work like I would expect when killing things run after this command. But canceling an install acts differently from cancelling a normal install:
image

This is repeatable for some reason, @wolfv or @baszalmstra would you know why that could happen? e.g. did I just introduce a terrible bug that my testing isn't verifying?

@wolfv
Copy link
Member

wolfv commented Dec 19, 2024

This is what the docs say. I wonder if we're in this situation - and need to come up with our own way of killing the remaining threads.

Screenshot 2024-12-19 at 17 06 07

@ruben-arts ruben-arts marked this pull request as draft January 16, 2025 10:21
@Hofer-Julian Hofer-Julian marked this pull request as ready for review January 23, 2025 10:30
@Hofer-Julian
Copy link
Contributor

This PR is ready for review.

I tried to react on ctrl-c via tokio as suggested by @wolfv, but I couldn't get it to work. In order to reset the cursor, one has to write to stdout, and as far as I can tell no print goes through in that context.

When using the ctrl_c crate, everything works as expected.

@ruben-arts
Copy link
Contributor Author

I retested it and it did indeed fix the issues I had. So I'll merge it.

@ruben-arts ruben-arts merged commit 263e077 into prefix-dev:main Jan 23, 2025
28 checks passed
@wolfv
Copy link
Member

wolfv commented Jan 23, 2025

I tried to react on ctrl-c via tokio as suggested by @wolfv, but I couldn't get it to work. In order to reset the cursor, one has to write to stdout, and as far as I can tell no print goes through in that context.

Interesting. Even with flush?

But - whatever works! :)

@Hofer-Julian
Copy link
Contributor

Interesting. Even with flush?

I didn't try flushing, but since stdout is line-buffered, it should still have worked with println!

@wolfv
Copy link
Member

wolfv commented Jan 23, 2025

Not sure if that is still true when the terminal is e.g. set into raw mode for the selector thing.

@Hofer-Julian
Copy link
Contributor

Not sure if that is still true when the terminal is e.g. set into raw mode for the selector thing.

Mmmh interesting, will try flushing tomorrow

@Hofer-Julian
Copy link
Contributor

Flushing doesn't help, unfortunately, let's stick with the ctrlc crate for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cursor disapear after ctrl+c in a pixi menu
4 participants